//
//  WSMineUserCell.m
//  CharonTVProject
//
//  Created by karong on 2023/8/4.
//

#import "WSMineUserCell.h"

@interface WSMineUserCell ()
@property (weak, nonatomic) IBOutlet UIImageView *userImageView;

@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *userSignLabel;
@property (weak, nonatomic) IBOutlet UIButton *vipBtn;
@property (weak, nonatomic) IBOutlet UIButton *coinBtn;

@property (weak, nonatomic) IBOutlet UILabel *vip_expires_titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *vip_expires_textLabel;
@property (weak, nonatomic) IBOutlet UILabel *coinsLabel;
@property (weak, nonatomic) IBOutlet UIImageView *vipImageView;

@end

@implementation WSMineUserCell

- (void)setDataWithObject:(WSUser *)object {
    if(appUserCenter.isLogin) {
        [self.userImageView sd_setImageWithURL:[NSURL URLWithString:object.avatar] placeholderImage:WSPlaceholderImage];
        self.userNameLabel.text = object.user_name;
        self.userSignLabel.text = WSSF(@"ID:%ld", (long)object.id);
        self.vip_expires_titleLabel.text = (appUserCenter.vip_status == 1)? APPLocalized(@"VIP剩餘天數"):APPLocalized(@"開通VIP會員");
        self.vip_expires_textLabel.text = (appUserCenter.vip_status == 1)? object.vip_expires_text:APPLocalized(@"看精彩熱劇大片");
        self.coinsLabel.text = WSSF(@"%@：%ld剧豆", APPLocalized(@"餘額"), (long)appUserCenter.coins);
        self.vipImageView.hidden = appUserCenter.vip_status != 1;
    }else{
        self.userImageView.image = WSPlaceholderImage;
        self.userNameLabel.text = @"注册/登录";
        self.userSignLabel.text = @"点击进行登录";
        self.vip_expires_titleLabel.text = APPLocalized(@"開通VIP會員");
        self.vip_expires_textLabel.text =APPLocalized(@"看精彩熱劇大片");
        self.coinsLabel.text = WSSF(@"%@：%ld剧豆", APPLocalized(@"餘額"), (long)appUserCenter.coins);
        self.vipImageView.hidden = appUserCenter.vip_status != 1;
    }

}

- (IBAction)userInfoAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(mineUserCellUserAction)]) {
        [self.delegate mineUserCellUserAction];
    }
}
- (IBAction)vipAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(mineUserCellVipAction)]) {
        [self.delegate mineUserCellVipAction];
    }
}
- (IBAction)coinAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(mineUserCellCoinAction)]) {
        [self.delegate mineUserCellCoinAction];
    }
}
@end
